#define ROW_HEADER_WIDTH_DEF	35
#define ROW_HEADER_WIDTH_K		40
#define ROW_HEADER_WIDTH_10K	45
#define COL_HEADER_HEIGHT		CELL_DEFHEIGHT

class SheetView
{
public:
	enum AREA{
		CORNER_BUTTON = 0,
		ROW_HEADER = 1,
		ROW_LINE = 2,
		COL_HEADER = 3,
		COL_LINE = 4,
		GRID_AREA = 5};
	SheetView();
	~SheetView();
	void ReadColumnWidth();
	void ReadRowHeight();
	void SetClientSize(int x, int y);
	const CELLPOS& GetLeftCorner() {return leftCornerCell;}
	const CELLPOS& GetSelecting() {return selectingCell;}
	const CELLPOS& GetRegionStart() {return regionStartCell;}
	const CELLPOS& GetRegionEnd() {return regionEndCell;}
	void SetLeftCorner(ROW_NUM iRow, COL_NUM iCol);
	bool SetSelectingCell(ROW_NUM iRow, COL_NUM iCol);
	void SetRegionStart(ROW_NUM iRow, COL_NUM iCol);
	void SetRegionEnd(ROW_NUM iRow, COL_NUM iCol, bool HScroll =true, bool VScroll=true);
	void ScrollDown(ROW_NUM i);
	void ScrollUp(ROW_NUM i);
	void ScrollRight(ROW_NUM i);
	void ScrollLeft(ROW_NUM i);
	int* GetColLinesArr(){return arrColLines;}
	int* GetRowLinesArr(){return arrRowLines;}
	const int GetColLinesCount(){return colLines.GetCount();}
	const int GetRowLinesCount(){return rowLines.GetCount();}
	const int GetRowHeaderWidth();
	const int GetColHeaderHeight(){return (int)(colHeaderHeight * ApplicationSetting::Zooming);}
	void nToA(int n, PTSTR outszStr);
	RECT GetSelectingRect();
	RECT GetRegionRect();
	RECT GetCellRect(ROW_NUM iRow, ROW_NUM iCol);
	RECT GetRegionCellRect(ROW_NUM iRow, ROW_NUM iCol);
	AREA CheckArea(int x, int y, ROW_NUM& iRow, COL_NUM& iCol);
	void CheckCell(int x, int y, ROW_NUM& iRow, COL_NUM& iCol);
	void BeginSetColWidth(COL_NUM iCol){iColSet = iCol;}
	void SetColWidth(int Width);
	void EndSetColWidth(COL_NUM& iCol, int& NewWidth);
	void BeginSetRowHeight(ROW_NUM iRow){iRowSet = iRow;}
	void SetRowHeight(int Height);
	void EndSetRowHeight(ROW_NUM& iRow, int& NewHeight);
	bool InRegion(const CELLPOS& Pos);
private:
	int xClient, yClient;
	Sheet* pSheet;
	LinkedList<int> colLines, rowLines;
	int* arrColLines;
	int* arrRowLines;
	CELLPOS leftCornerCell;
	CELLPOS selectingCell;
	CELLPOS regionStartCell;
	CELLPOS regionEndCell;
	int rowHeaderWidth;
	int colHeaderHeight;
	static int iColSet, iRowSet;
};